import { Prisma, PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();

async function main() {
    const subscriptionPlanList: Prisma.SubscriptionPlanUncheckedCreateInput[] = [
        {
            name: 'Free',
            price: 0,
            description: 'Free plan',
            features: JSON.stringify([
                {key: 'Call times', value: '100'},
                {key: 'Full page screenshots', value: 0},
                {key: 'Supports pc', value: 1},
                {key: 'Supports mobile phones', value: 0},
                {key: 'Support setting pixel ratio', value: 0},
            ])
        },
        {
            name: 'Pro',
            price: 5,
            description: 'Pro plan',
            features: JSON.stringify([
                {key: 'call times', value: 'infinite'},
                {key: 'Full page screenshots', value: 1},
                {key: 'Supports pc', value: 1},
                {key: 'Supports mobile phones', value: 1},
                {key: 'Support setting pixel ratio', value: 1},
           ])
        }
    ];
    for (const item of subscriptionPlanList) {
        await prisma.subscriptionPlan.upsert({
            where: {name: item.name},
            update: item,
            create: item
        });
    }
    console.log('subscriptionPlan seed success');
}

main().finally(async () => {
    await prisma.$disconnect()
});
